package com.yuke.cloud.service.omc.controller.frontend;

/*
 * <p>Company: Copyright (c) 2018. yuke All Rights Reserved. </br> </p>
 * <p>Title：yuke-mall </br> </p>
 * <p>com.yuke.cloud.service.omc.controller.frontend Description TODO </br> </p>
 * @Author wg
 * @Date   2020/5/2 17:02
 */

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yuke.cloud.common.core.support.BaseController;
import com.yuke.cloud.common.util.excel.ExcelOutUtil;
import com.yuke.cloud.common.util.excel.RequestUtil;
import com.yuke.cloud.common.util.excel.ZipUtil;
import com.yuke.cloud.common.util.wrapper.Wrapper;
import com.yuke.cloud.service.omc.dto.OdsPointsDto;
import com.yuke.cloud.service.omc.dto.OrderShopDto;
import com.yuke.cloud.service.omc.dto.ShopOrderGoodsDto;
import com.yuke.cloud.service.omc.entity.OdsBill;
import com.yuke.cloud.service.omc.entity.OdsOrder;
import com.yuke.cloud.service.omc.service.OdsOrderService;
import com.yuke.cloud.service.omc.service.OdsPointsService;
import com.yuke.cloud.service.omc.utils.DateUtil;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import static com.yuke.cloud.common.util.excel.ExcelOutUtil.getMergePaperPath;
import static com.yuke.cloud.common.util.excel.ExcelOutUtil.helpdown;
import static com.yuke.cloud.common.util.excel.ZipUtil.fileToZip;

/**
 * 导出报表
 *
 * @return
 */
@Slf4j
@RestController
@RequestMapping("/ods/order")
public class OdsExcelOut extends BaseController {
    @Resource
    private OdsOrderService odsOrderService;
    @Resource
    private OdsPointsService odsPointsService;
    @Resource
    private OdsBillController odsBillController;

    private String fileName = "订单信息";

    //@GetMapping("/export")
    @RequestMapping("/export")
    @ResponseBody
    public void export(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String m = request.getMethod();
        JSONObject jsonObject=null;
        if (m.toLowerCase().equals("get")){
            jsonObject = RequestUtil.getParm2Json(request) ;
        }else{
            jsonObject = RequestUtil.postParm2Json(request);
        }

        System.out.println("参数："+jsonObject);
        int page = 1;
        int size = 1000;
        if (jsonObject.get("page") != null && jsonObject.get("size") != null) {
            page = Integer.valueOf(jsonObject.get("page").toString());
            size = Integer.valueOf(jsonObject.get("size").toString());
            System.out.println(page+","+size);
        }
        if (jsonObject.get("beginTime") != null && jsonObject.get("endTime") != null && !jsonObject.get("beginTime").equals("")) {
            Long beginTime = Long.parseLong(jsonObject.get("beginTime").toString());
            Long endTime = Long.parseLong(jsonObject.get("endTime").toString());
            jsonObject.put("beginTime",new Date(beginTime));
            jsonObject.put("endTime",new Date(endTime));
        }
         if (getGroupInfoDto().getGroupId() != null && getGroupInfoDto().getGroupId() > 1) {

            Long groupId = getGroupInfoDto().getGroupId();
            // 登录人为3级部门
            if (getGroupInfoDto().getLevel().toString().equals("3")) {
                groupId = getGroupInfoDto().getParentId();

            }
            jsonObject.put("groupId",groupId);
        }



        //excel标题
        String[] title ={ "序号", "订单号", "下单时间", "联系人", "联系电话", "应付金额(元)", "已付金额(元)", "订单状态", "支付类型", "付款状态", "物流状态", "所属店铺", "所属仓库", "订单类型", "结算/返利状态", "结算/返利金额(元)"};
        String [] properties = new String[]{"index", "orderId", "createTime", "consignee", "mobile", "amountPayableDouble", "amountPaidDouble", "orderStatus", "payType", "payStatus", "shippingStatus", "shopName", "warehouseName", "orderType", "isCheckout", "amountCheckout"};

        //sheet名
        String sheetName = "订单信息表";

        //不同系统文件夹的生成
        String mergePaperPath = ExcelOutUtil.getMergePaperPath(new Date());


        ZipUtil zipUtil = new ZipUtil();


        boolean flag =true;

        //存入地址
        List<File> tempPath = new ArrayList<>();

        while(flag){
            jsonObject.put("page",page);
            //获取数据
            List<OdsOrder> list = odsOrderService.search(jsonObject);
            int i=0;
            List<Map> map = new ArrayList<>();
            for (OdsOrder odsOrder : list) {

                BigDecimal b = new BigDecimal((float)odsOrder.getAmountPayable()/100);

                Double result = b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();

                BigDecimal c = new BigDecimal((float)odsOrder.getAmountPaid()/100);

                Double result2 = c.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();

                Map value = JSON.parseObject(JSON.toJSONString(odsOrder), Map.class);
                i++;
                switch (value.get("orderStatus").toString()) {
                    case "0": value.put("orderStatus","未确认");
                        break;//改变值
                    case "1": value.put("orderStatus","已确认");
                        break;
                    case "2": value.put("orderStatus","已完成");
                        break;
                    case "3": value.put("orderStatus","已取消");
                        break;
                    case "4": value.put("orderStatus","已退货/退款");
                        break;
                    case "5": value.put("orderStatus","部分退货/退款");
                        break;
                    case "6": value.put("orderStatus","无效作废");
                        break;
                    default :
                        value.put("orderStatus","未确认");
                }

                switch (value.get("payType").toString()) {
                    case "0": value.put("payType","货到付款");
                        break;//改变值
                    case "1": value.put("payType","在线支付(银行/银联)");
                        break;
                    case "2": value.put("payType","在线支付(支付宝)");
                        break;
                    case "3": value.put("payType","在线支付（微信）");
                        break;
                    case "4": value.put("payType","个人账户支付");
                        break;
                    case "5": value.put("payType","积分支付");
                        break;
                    case "6": value.put("payType","积分混合积分+支付宝");
                        break;
                    case "7": value.put("payType","积分混合积分加微信");
                        break;
                    case "8": value.put("payType","线下手工单");
                        break;
                    case "9": value.put("payType","免费送");
                        break;
                    default :
                        value.put("payType","货到付款");
                }

                switch (value.get("payStatus").toString()) {
                    case "0": value.put("payStatus","未支付");
                        break;//改变值
                    case "1": value.put("payStatus","已支付");
                        break;
                    default :
                        value.put("payStatus","未支付");
                }

                switch (value.get("shippingStatus").toString()) {
                    case "0": value.put("shippingStatus","未发货");
                        break;//改变值
                    case "1": value.put("shippingStatus","备货中");
                        break;
                    case "2": value.put("shippingStatus","已（开始）发货");
                        break;
                    case "3": value.put("shippingStatus","已收货");
                        break;
                    default :
                        value.put("payshippingStatusStatus","已收货");
                }

                switch (value.get("orderType").toString()) {
                    case "0": value.put("orderType","未知");
                        break;//改变值
                    case "1": value.put("orderType","消费者向店铺下单");
                        break;
                    case "2": value.put("orderType","店铺向平台仓库下单");
                        break;
                    default :
                        value.put("orderType","店铺向平台仓库下单");
                }

                value.put("amountPayableDouble",result);

                value.put("amountPaidDouble",result2);

                value.put("createTime",DateUtil.getStringDate(odsOrder.getCreateTime()));

                value.put("index",i+"");

                map.add(value);

            }

            //创建HSSFWorkbook
            ExcelOutUtil excelExport2 = new ExcelOutUtil();
            excelExport2.setFileName(fileName);
            excelExport2.setData(map);
            excelExport2.setHeardKey(properties);
            excelExport2.setFontSize(14);
            excelExport2.setSheetName(sheetName);
            excelExport2.setTitle(sheetName);
            excelExport2.setHeardList(title);
            //传入文件目录以便excel存入

            String s = excelExport2.exportExport(request, response, page, 1, mergePaperPath);



            tempPath.add(new File(s));


            if (list == null || list.size() < 1000){
                System.out.println("数据不足1000");
                flag=false;
                break;
            }
            System.out.println("循环加一");

            page++;
            System.out.println(page);
        }

        fileToZip(mergePaperPath,mergePaperPath,fileName);
        ExcelOutUtil.helpdown(request,response,mergePaperPath+fileName+".zip");

        //删除文件
        for (File temp : tempPath) {
            System.out.println(temp);
            temp.delete();
        }

        //删除 压缩包
        new File(mergePaperPath+"订单信息.zip").delete();
        new File(mergePaperPath).delete();

    }

    @RequestMapping("/getOrderExcel")
    @ResponseBody
    public void exportOrderExcel(HttpServletRequest request,HttpServletResponse response) throws IOException {

        JSONObject jsonObject= RequestUtil.getParm2Json(request) ;
        OrderShopDto orderShopDto = new OrderShopDto();

        System.out.println("参数："+jsonObject);
        int page=1;
        int size=1000;

        if (jsonObject.get("page") != null && jsonObject.get("size") != null) {
            page = Integer.valueOf(jsonObject.get("page").toString());
            size = Integer.valueOf(jsonObject.get("size").toString());
            System.out.println(page+","+size);
        }
        if (jsonObject.get("beginTime") != null && jsonObject.get("endTime") != null){
            orderShopDto.setBeginTime(DateUtil.getStringDate(new Date(Long.parseLong(jsonObject.get("beginTime").toString()))));
            orderShopDto.setEndTime(DateUtil.getStringDate(new Date(Long.parseLong(jsonObject.get("endTime").toString()))));
        }
        if (jsonObject.get("minOrder") != null){
            orderShopDto.setMinOrder(Integer.valueOf(jsonObject.get("minOrder").toString()));
        }
        if (jsonObject.get("maxOrder") != null){
            orderShopDto.setMaxOrder(Integer.valueOf(jsonObject.get("maxOrder").toString()));
        }
        if (jsonObject.get("minMoney") != null){
            orderShopDto.setMinMoney(Integer.valueOf(jsonObject.get("minMoney").toString()));
        }
        if (jsonObject.get("maxMoney") != null){
            orderShopDto.setMaxMoney(Integer.valueOf(jsonObject.get("maxMoney").toString()));
        }
        System.out.println("参数："+orderShopDto);
        //excel标题
        String[] title ={ "序号", "店铺名称", "下单次数", "下单金额(元)","实付金额()元","联系电话", "店铺地址",};
        String [] properties = new String[]{"index", "shopName", "orderCount", "amountPayable","amountPaidCount","telephone", "address"};
        //excel文件名
        String fileName = "订单统计" + System.currentTimeMillis() + ".xls";

        //sheet名
        String sheetName = "订单统计表";


        //不同系统文件夹的生成
        String mergePaperPath = getMergePaperPath(new Date());


        ZipUtil zipUtil = new ZipUtil();

        boolean flag =true;

        //存入地址
        List<File> tempPath = new ArrayList<>();

        while(flag){

            List<Map> map = new ArrayList<>();
            int index = 1;
            PageHelper.startPage(page, size);
            List<OrderShopDto> order = odsOrderService.getOrderInformation(orderShopDto);
            PageInfo pageInfo = new PageInfo(order);
            List<OrderShopDto> list = pageInfo.getList();

            for (OrderShopDto shopDto : list) {
                Map value = JSON.parseObject(JSON.toJSONString(shopDto), Map.class);
                value.put("index",index++);
                map.add(value);
            }

            //创建HSSFWorkbook
            ExcelOutUtil orderExcel = new ExcelOutUtil();
            orderExcel.setFileName(fileName);
            orderExcel.setData(map);
            orderExcel.setHeardKey(properties);
            orderExcel.setFontSize(14);
            orderExcel.setSheetName(sheetName);
            orderExcel.setTitle(sheetName);
            orderExcel.setHeardList(title);

            String s = orderExcel.exportExport(request, response, page, 2, mergePaperPath);

            tempPath.add(new File(s));

            if (list == null || list.size() < 1000){
                flag=false;
                break;
            }

            page++;
        }

        fileToZip(mergePaperPath,mergePaperPath,"订单统计信息");
        helpdown(request,response,mergePaperPath+"订单统计信息.zip");

        //删除文件
        for (File temp : tempPath) {
            temp.delete();
        }
        //删除 压缩包
        new File(mergePaperPath+"订单统计信息.zip").delete();

    }
    //积分管理导出excel
    @RequestMapping("/membershipScore")
    @ResponseBody
    public void exportMembershipScore(@ApiParam(name = "page", value = "分页值", defaultValue = "1") @RequestParam(defaultValue = "1") Integer page,
                                      @ApiParam(name = "size", value = "每分页返回的记录数", defaultValue = "1000") @RequestParam(defaultValue = "1000") Integer size,
                                      @ApiParam(name = "loginName", value = "每分页返回的记录数", defaultValue = "") @RequestParam(required = false) String loginName,
                                      @ApiParam(name = "pointType", value = "每分页返回的记录数", defaultValue = "0") @RequestParam(required = false) Byte pointType,
                                      @ApiParam(name = "pointAspect", value = "每分页返回的记录数", defaultValue = "0") @RequestParam(required = false) Byte pointAspect,
                                      HttpServletRequest request,HttpServletResponse response) throws IOException {

        OdsPointsDto odsPointsDto = new OdsPointsDto();
        if (loginName != null && loginName != "" ){
            odsPointsDto.setLoginName(loginName);
        }
        if (pointType != null){
            odsPointsDto.setPointType(pointType);
        }
        if (pointAspect != null ){
            odsPointsDto.setPointAspect(pointAspect);
        }

        //excel标题
        String[] title ={ "序号", "用户名", "积分数", "积分余额", "积分类型", "用户类型","订单号","序列号"};

        String [] properties = new String[]{"index", "loginName", "number", "pointBalance","pointType", "pointAspect", "orderId","serialNum"};
        //excel文件名
        String fileName = "积分信息" + System.currentTimeMillis() + ".xls";

        //sheet名
        String sheetName = "积分信息统计表";

        //zip文件名
        String zipName = "积分信息统计表";

        //zip路径名
        String zipNameString = zipName+".zip";

        //不同系统文件夹的生成
        String mergePaperPath = getMergePaperPath(new Date());

        ZipUtil zipUtil = new ZipUtil();

        //存入地址
        List<File> tempPath = new ArrayList<>();

        boolean flag =true;

        while(flag){

            List<Map> map = new ArrayList<>();

            PageHelper.startPage(page, size);

            int index = 1;

            List<OdsPointsDto> list1 = odsPointsService.findPoints(odsPointsDto);

            PageInfo<OdsPointsDto> pageInfo = new PageInfo<>(list1);

            List<OdsPointsDto> list = pageInfo.getList();

            for (OdsPointsDto odspointsDto : list) {
                Map value = JSON.parseObject(JSON.toJSONString(odspointsDto), Map.class);

                switch(odspointsDto.getPointType().toString()){

                    case "0" :value.put("pointType","支出");
                        break;
                    case "1" :value.put("pointType","购物积分");
                        break;
                    case "2" :value.put("pointType","签到积分");
                        break;
                    case "3" :value.put("pointType","奖券积分");
                        break;
                    case "4" :value.put("pointType","充值积分");
                        break;
                    case "8" :value.put("pointType","取消订单扣减积分");
                        break;
                    case "9" :value.put("pointType","其他");
                        break;
                    default:
                }
                switch(odspointsDto.getPointAspect().toString()){

                    case "1" :value.put("pointAspect","用户端");
                        break;
                    case "2" :value.put("pointAspect","商家端");
                        break;
                    default:
                }
                value.put("index",index++);
                map.add(value);
            }


            //创建HSSFWorkbook
            ExcelOutUtil excelExport = new ExcelOutUtil();
            excelExport.setFileName(fileName);
            excelExport.setData(map);
            excelExport.setHeardKey(properties);
            excelExport.setFontSize(14);
            excelExport.setSheetName(sheetName);
            excelExport.setTitle(sheetName);
            excelExport.setHeardList(title);
            String s = excelExport.exportExport(request, response, page, 2, mergePaperPath);

            tempPath.add(new File(s));

            if (list == null || list.size() < size){
                flag=false;
                break;
            }

            page++;
        }

        fileToZip(mergePaperPath,mergePaperPath,zipName);

        helpdown(request,response,mergePaperPath+zipNameString);

        //删除文件
        for (File temp : tempPath) {
            temp.delete();
        }
        //删除 压缩包
        new File(mergePaperPath+zipNameString).delete();
    }


    //账单管理导出excel
    @RequestMapping("/billExcel")
    @ResponseBody
    public void exportBill(@ApiParam(name = "page", value = "分页值", defaultValue = "0") @RequestParam(defaultValue = "1") Integer page,
                           @ApiParam(name = "size", value = "每分页返回的记录数", defaultValue = "0") @RequestParam(defaultValue = "1000") Integer size,
                           @ApiParam(name = "loginName", value = "每分页返回的记录数", defaultValue = "") @RequestParam(required = false) String loginName,
                           @ApiParam(name = "billType", value = "每分页返回的记录数", defaultValue = "0") @RequestParam(required = false) Byte billType,
                           @ApiParam(name = "balanceType", value = "每分页返回的记录数", defaultValue = "0") @RequestParam(required = false) Byte balanceType,
                           HttpServletRequest request,HttpServletResponse response) throws IOException {
        OdsBill odsBill = new OdsBill();
        if (loginName != null && loginName != "" ){
            odsBill.setLoginName(loginName);
        }
        if (billType != null){
            odsBill.setBillType(billType);
        }
        if (balanceType != null ){
            odsBill.setBalanceType(balanceType);
        }


        //excel标题
        String[] title ={ "序号", "用户名", "订单号", "账单金额(元)", "资金余额(元)", "账单类型","流水号","账单状态"};

        String [] properties = new String[]{"index", "loginName", "orderIds", "amountDouble","balanceDouble", "billType", "serialNum","balanceType"};
        //excel文件名
        String fileName = "账单管理" + System.currentTimeMillis() + ".xls";

        //sheet名
        String sheetName = "账单管理统计表";

        //zip文件名
        String zipName = "账单管理统计表";

        //zip路径名
        String zipNameString = zipName+".zip";

        //不同系统文件夹的生成
        String mergePaperPath = getMergePaperPath(new Date());

        ZipUtil zipUtil = new ZipUtil();

        //存入地址
        List<File> tempPath = new ArrayList<>();

        boolean flag =true;

        while(flag){

            List<Map> map = new ArrayList<>();

            Wrapper<PageInfo<OdsBill>> list1 = odsBillController.list(page, size, odsBill);

            PageInfo<OdsBill> result = list1.getResult();

            List<OdsBill> list = result.getList();

            int index = 1;

            for (OdsBill odsBills : list) {

                BigDecimal b = new BigDecimal((float)odsBills.getAmount()/100);

                Double mountDouble  = b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();

                BigDecimal c = new BigDecimal((float)odsBills.getBalance()/100);

                Double cDouble = c.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();

                Map value = JSON.parseObject(JSON.toJSONString(odsBills), Map.class);

                switch(odsBills.getBalanceType().toString()){

                    case "0" :value.put("balanceType","支付中");
                        break;
                    case "1" :value.put("balanceType","已完成");
                        break;
                    case "2" :value.put("balanceType","取消");
                        break;
                }
                if (odsBills.getBillType()!=null) {
                    switch (odsBills.getBillType().toString()) {

                        case "0":
                            value.put("billType", "消费");
                            break;
                        case "1":
                            value.put("billType", "在线支付(银行/银联)");
                            break;
                        case "2":
                            value.put("billType", "在线支付(支付宝)");
                            break;
                        case "3":
                            value.put("billType", "在线支付（微信）");
                            break;
                        case "4":
                            value.put("billType", "平台返现");
                            break;
                        case "5":
                            value.put("billType", "平台佣金");
                            break;
                        case "6":
                            value.put("billType", "取消订单返还");
                            break;
                    }
                }
                value.put("index",index++);

                value.put("amountDouble",mountDouble);

                value.put("balanceDouble",cDouble);

                map.add(value);
            }


            //创建HSSFWorkbook
            ExcelOutUtil excelExport = new ExcelOutUtil();
            excelExport.setFileName(fileName);
            excelExport.setData(map);
            excelExport.setHeardKey(properties);
            excelExport.setFontSize(14);
            excelExport.setSheetName(sheetName);
            excelExport.setTitle(sheetName);
            excelExport.setHeardList(title);
            String s = excelExport.exportExport(request, response, page, 2, mergePaperPath);

            tempPath.add(new File(s));

            if (list == null || list.size() < size){
                flag=false;
                break;
            }

            page++;
        }


        fileToZip(mergePaperPath,mergePaperPath,zipName);

        helpdown(request,response,mergePaperPath+zipNameString);

        //删除文件
        for (File temp : tempPath) {
            temp.delete();
        }
        //删除 压缩包
        new File(mergePaperPath+zipNameString).delete();
    }

    //导出某一个店铺下过的商品列表
    @RequestMapping("/orderGoods")
    @ResponseBody
    public void orderGoods(@ApiParam(name = "page", value = "分页值", defaultValue = "0") @RequestParam(defaultValue = "1") Integer page,
                           @ApiParam(name = "size", value = "每分页返回的记录数", defaultValue = "0") @RequestParam(defaultValue = "1000") Integer size,
                           @ApiParam(name = "shopId", value = "店铺名称", defaultValue = "") @RequestBody ShopOrderGoodsDto shopOrderGoodsDto,
                           HttpServletRequest request,HttpServletResponse response) throws IOException {

        //excel标题
        String[] title ={ "序号","订单号", "订单状态","订单创建时间","订单联系人", "订单地址", "商品名称","数量", "商品销售价格", "商品实际销售价格"};

        String [] properties = new String[]{"index", "orderId", "orderStatus","createTime","consignee","address", "specName","goodsNum", "goodsPrice","payPrice"};
        //excel文件名
        String fileName = "订单商品明细" + System.currentTimeMillis() + ".xls";

        //sheet名
        String sheetName = "订单商品明细";

        //zip文件名
        String zipName = "订单商品明细";

        //zip路径名
        String zipNameString = zipName+".zip";

        //不同系统文件夹的生成
        String mergePaperPath = getMergePaperPath(new Date());

        //存入地址
        List<File> tempPath = new ArrayList<>();

        boolean flag =true;

        while(flag){

            List<Map> map = new ArrayList<>();

            PageHelper.startPage(page, size);

            List<ShopOrderGoodsDto> list = odsOrderService.findOrderGoods(shopOrderGoodsDto);

            PageInfo<ShopOrderGoodsDto> pageInfo = new PageInfo<>(list);

            List<ShopOrderGoodsDto> infoList = pageInfo.getList();

            int index = 1;

            for (ShopOrderGoodsDto orderGoodsDto : infoList) {

                Map value = JSON.parseObject(JSON.toJSONString(orderGoodsDto), Map.class);

                BigDecimal a = new BigDecimal((float)orderGoodsDto.getGoodsPrice()/100);

                Double goodsDouble  = a.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();

                BigDecimal b = new BigDecimal((float)orderGoodsDto.getPayPrice()/100);

                Double priceDouble  = b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();

                    switch (orderGoodsDto.getOrderStatus().toString()) {
                        case "0": value.put("orderStatus","未确认");
                            break;
                        case "1": value.put("orderStatus","已确认");
                            break;
                        case "2": value.put("orderStatus","已完成");
                            break;
                        case "3": value.put("orderStatus","已取消");
                            break;
                        case "4": value.put("orderStatus","已退货/退款");
                            break;
                        case "5": value.put("orderStatus","部分退货/退款");
                            break;
                        case "6": value.put("orderStatus","无效作废");
                            break;
                        default :
                            value.put("orderStatus","未确认");
                    }
                value.put("index",index++);

                value.put("goodsPrice",goodsDouble);

                value.put("payPrice",priceDouble);

                value.put("createTime",DateUtil.getStringDate(orderGoodsDto.getCreateTime()));

                map.add(value);
            }


            //创建HSSFWorkbook
            ExcelOutUtil excelExport = new ExcelOutUtil();
            excelExport.setFileName(fileName);
            excelExport.setData(map);
            excelExport.setHeardKey(properties);
            excelExport.setFontSize(14);
            excelExport.setSheetName(sheetName);
            excelExport.setTitle(sheetName);
            excelExport.setHeardList(title);
            String s = excelExport.exportExport(request, response, page, 2, mergePaperPath);

            tempPath.add(new File(s));

            if (list == null || list.size() < size){
                flag=false;
                break;
            }

            page++;
        }


    fileToZip(mergePaperPath,mergePaperPath,zipName);

        helpdown(request,response,mergePaperPath+zipNameString);

        //删除文件
        for (File temp : tempPath) {
            temp.delete();
        }
        //删除 压缩包
        new File(mergePaperPath+zipNameString).delete();
    }


}
